# 有文件a.txt
# 内容如下:
# 我爱你python, 我爱你
#
# 写代码,把a.txt内容中的python替换为world
from datetime import datetime
from pprint import pprint
import random


# file=open("./a.txt","r",encoding="utf-8")
# content=file.read()
# file.close()
# contents = content.replace("python", "world")
#
# file=open("./a.txt","w",encoding="utf-8")
# file.write(contents)
# file.close()
# 有文件a.txt
# 内容如下:
#
# 我爱你python, 我爱你
#
# 有文件b.txt
# 内容如下:
#
# hello
#
# 把文件a.txt和b.txt合并为c.txt


# file=open("./a.txt","r",encoding="utf-8")
# contentA=file.read()
# file.close()
#
# file=open("./b.txt","r",encoding="utf-8")
# contentB=file.read()
# file.close()
#
# file=open("./c.txt","w",encoding="utf-8")
# file.write(f"{contentA}\n{contentB}")
# file.close()

# 有文件a.txt,有很多行,只显示偶数行

# file=open("./a.txt","r",encoding="utf-8")
# contentA_list=file.readlines()
# for a in range(0,len(contentA_list),2):
#     print(contentA_list[a]+12)
#
# file.close()

# 练习题：
# 定义一副扑克牌，以列表保存，每个扑克以小列表保存 [["红桃",1],["红桃",2]...]
# 定义四个玩家，名字自定义。
# 让四个玩家随机抽取扑克牌，将抽取的过程写入文件中。
# 过程为一句话： "XXX在XXXX时间抽到了一张牌为：XXXX"
# 一共100次机会，每个玩家和牌完全随机

def poke():
    poke_list=["大王","小王"]
    hua_se=["红桃","黑桃","方块","梅花"]
    for huase in hua_se:
        for a in range(1,14):
            poke_list.append([huase,a])
    return poke_list

def play():
    pleyer=["玩家1","玩家2","玩家3","玩家4"]
    file=open("poke.txt","a",encoding="utf8")
    for ci in range(100):
        s=f"{random.choice(pleyer)}在{datetime.now()}时间抽到了一张牌为：{random.choice(poke())}\n"
        file.write(s)
    file.close()

play()


list1=["大王","小王"]+[["红桃",i] for i in range(1,14)]+[["方片",i] for i in range(1,14)]+[["梅花",i] for i in range(1,14)]+[["草花",i] for i in range(1,14)]

pprint(list1)







